package com.itheima;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.aliyun.oss.model.PutObjectRequest;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

public class OSSDemo {

    public static void main(String[] args) throws FileNotFoundException {
        String endpoint = "oss-cn-beijing.aliyuncs.com"; //域名

        String accessKeyId = "LTAI4G75D4ZHHuwN2hEVp1m676";
        String accessKeySecret = "oSRndFELgxKX8u0HFXm1IJKS7pJ86767";

        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);
        PutObjectRequest putObjectRequest = new PutObjectRequest("nineclock-heima", "00000008.jpg", new File("C:\\Users\\itheima\\Pictures\\素材1\\4.jpg"));

        ossClient.putObject(putObjectRequest);
        ossClient.shutdown();
    }




    private static void uploadStream() throws FileNotFoundException {
        String endpoint = "oss-cn-beijing.aliyuncs.com"; //域名

        String accessKeyId = "LTAI4G75D4ZHHuwN2hEVp1m23239";
        String accessKeySecret = "oSRndFELgxKX8u0HFXm1IJK2323S7pJ8wf";

        // 创建OSSClient实例。
        OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret);

        InputStream inputStream = new FileInputStream("C:\\Users\\itheima\\Pictures\\素材1\\007.jpg");
        ossClient.putObject("nineclock-heima", "000000007.jpg", inputStream);

        // 关闭OSSClient。
        ossClient.shutdown();
    }

}
